﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Face_Recognition
{
    public class Hole
    {
        List<int[]> coordinates;

        Hole closest;

        float proportion;

        int area;
        int xmax, xmin, ymax, ymin;

        public int Ymin
        {
            get { return ymin; }
            set { ymin = value; }
        }

        public int Ymax
        {
            get { return ymax; }
            set { ymax = value; }
        }

        public int Xmin
        {
            get { return xmin; }
            set { xmin = value; }
        }

        public int Xmax
        {
            get { return xmax; }
            set { xmax = value; }
        }

        public float Proportion
        {
            get { return proportion; }
            set { proportion = value; }
        }

        public Hole Closest
        {
            get { return closest; }
            set { closest = value; }
        }

        public List<int[]> Coordinates
        {
            get { return coordinates; }
            set { coordinates = value; }
        }
        Point center;

        public Point Center
        {
            get { return center; }
            set { center = value; }
        }
        List<int> distances;

        public List<int> Distances
        {
            get { return distances; }
            set { distances = value; }
        }

        public Hole(List<int[]> _coordinates)
        {
        
            coordinates = _coordinates;
            int xmin = coordinates[0][0];
            int xmax = coordinates[0][0];
            int ymin = coordinates[0][1];
            int ymax = coordinates[0][1];
                
            foreach(int[] p in _coordinates)
            {   
                if (p[0] > xmax)
                    xmax = p[0];
                if (p[0] < xmin)
                    xmin = p[0];
                if (p[1] > ymax)
                    ymax = p[1];
                if (p[1] < ymin)
                    ymin = p[1];
            }

            this.xmax = xmax;
            this.ymax = ymax;
            this.xmin = xmin;
            this.ymin = ymin;

            this.proportion =(float)(xmax - xmin)/(ymax - ymin);

            center = new Point((xmax + xmin) / 2, (ymax + ymin) / 2);
        }

        public int FindDistance(Hole h)
        {
            return (int)Math.Sqrt(Math.Pow(h.Center.X - this.center.X, 2) + Math.Pow(h.Center.Y - this.center.Y, 2));
        }
    }
}
